<?php
/**
 * Created by PhpStorm.
 * User: xiaoxin
 * Date: 2018/10/21 0021
 * Time: 15:01
 */

namespace app\index\controller;
use app\index\model\User;
use think\Controller;

class Edit extends Controller
{
	/**
	 * 个人资料主页
	 * @return mixed
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\ModelNotFoundException
	 * @throws \think\exception\DbException
	 */
	public function index(){
		$sex = User::where('uid',session('uid'))->field('sex,school,address')->find();
		$this->assign('sex',$sex);
		return $this->fetch();
	}

	/**
	 * 修改个人资料
	 */
	public function edits(){
		$post = input('post.');
		$res = User::where('uid', session('uid'))
			->update($post);
		if ($res){
			$this->success('已保存');
		}else{
			$this->error('保存失败，请稍后再试');
		}
	}
}